package edu.java.lectures.lec06.abstrclasses;

public class Triangle extends Figure {

    // private double a;
    private double b;
    private double c;

    public Triangle(double a, double b, double c) {
	super(a);
	this.b = b;
	this.c = c;
    }

    // --- Methods -------------------------------------------------------------

    @Override
    // covariant return type , test 1
    // Triangle is subtype of Figure
    public Triangle2 getMiSelf() {
	return new Triangle2(1, 2, 3);
    }

    // covariant return type , test 2
    // the return must be any child of Figure. But it is not necessary
    // to be only a subclass from the Triangles's branch
    // public Square getMiSelf() {
    // return new Square(1);
    // }

    @Override
    public double calculatePerimeter() {
	return getA() + b + c;
    }

    @Override
    public double calculateSurface() {
	double semiP = calculatePerimeter() / 2;
	double surface = Math.sqrt(semiP * (semiP - getA()) * (semiP - b)
		* (semiP - c));
	return surface;
    }

    // --- Getters and Setters -------------------------------------------------
    // public double getA() {
    // return a;
    // }
    //
    // public void setA(double a) {
    // this.a = a;
    // }

    public double getB() {
	return b;
    }

    public void setB(double b) {
	this.b = b;
    }

    public double getC() {
	return c;
    }

    public void setC(double c) {
	this.c = c;
    }
}
